<?php

require 'login_reg.php';
require 'photo_uploader.php';
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

if (isset($_POST['SubmitRegistrasi'])){
    //echo $_POST['UserName']. "<br/>";
    //echo $_POST['Password']. "<br/>";
    //echo $_POST['Password2']. "<br/>";
    //echo $_POST['FirstName']. "<br/>";
    //echo $_POST['LastName']. "<br/>";
    //echo $_POST['Birthday']. "<br/>";
    //echo $_POST['Location']. "<br/>";
    //echo $_POST['Hobby']. "<br/>";
    
    $reg = new login_reg();
    $ph = new photo_uploader();

    $nama = $_POST['FirstName']. " ". $_POST['LastName'];
    $reg->register($_POST['UserName'], $_POST['Password'], $nama, $_POST['Birthday'], $_POST['Location'], $_POST['Hobby']);

    //upload photo
//			$target_path = "images/" . basename( $_FILES['UserPhoto']['name']);
//                        echo basename( $_FILES['UserPhoto']['name']);
//
//			if(move_uploaded_file($_FILES['UserPhoto']['tmp_name'], $target_path)) {
//				//echo "File ".  basename( $_FILES['UserPhoto']['name']).
//				//" sudah diupload";
//			} else{
//				//echo "Error. Silakan coba lagi";
//			}
    //echo $_FILES['UserPhoto']['name'];
    $ph->upload_profpic($_POST['UserName'], $_FILES['UserPhoto']);
    $ph->set_profpic_id($_POST['UserName'], $ph->photo_id);
    header('Location: ../index.php?reg=1');

    
}

?>
